<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <!-- 
    .enter回车键
      <input v-on:keyup.enter="submit">
    
    .delete删除键
      <input v-on:keyup.delete="handle">
   -->
  <div id="app">
    <img src="../src/按键修饰符.jpg">
    <form action="#">
      <div>
        用户:<input type="text" @keyup.delete="clear" v-model="uname">
      </div>
      <div>
        密码:<input type="text" @keyup.enter="handleSubmit" v-model="pwd">
      </div>
      <input type="button" @click="handleSubmit" value="提交">
    </form>
  </div>
  <script src="../js/vue.js"></script>
  <script>
    const vm = new Vue({
      el: "#app",
      data: {
        uname: "",
        pwd: ""
      },
      methods: {
        handleSubmit() {
          console.log(`${this.uname}  ${this.pwd}`);
        },
        clear() { //按delete清空全部内容
          this.uname = "";
        }
      }
    });

  </script>
</body>

</html>
